<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>注册</title>
		<script type="text/javascript" src="jquery.min.js"></script>
	</head>
	<body>
		<div id="test">
			<form action="/reg.do" method="post" id="form">
				用户名: <input type="text" name="name" />
				密码: <input type="text" name="passwd" />
				手机号码: <input type="text" name="phone" />
				<input type="submit" id="sub" />
			</form>
		</div>
		<div id="img"></div>
		<p></p>
		<script type="text/javascript">
			$(function(){
				$('#form').submit(function(){
					$.ajax({
						type:"post",
						url:"http://127.0.0.1:8080/reg.do",
						data:$('#form').serialize(),
						success: function(result){
							alert("成功");
						},
						error: function(data){
							alert("错误:"+data.responseText);
						}
					});
				})
				$("#test").ajaxStart(function(){
					$(this).html("<img src='m6.jpg' />");
				})
				$('#test').ajaxStop(function(){
					$('p').html("ajax加载完成");
				})
			})
		</script>
	</body>
</html>